package com.android.baseconfig.data.http.retrofit2.func;

import com.android.baseconfig.base.BaseApiResult;
import com.android.baseconfig.data.http.retrofit2.exception.ApiException;

import io.reactivex.rxjava3.functions.Function;


/**
 * -----------------------------------------------------------------
 * Copyright (C) 2014-2016, by het, Shenzhen, All rights reserved.
 * -----------------------------------------------------------------
 * <p>
 * <p>描述：</p>
 * 名称:  <br>
 * 作者: uuxia<br>
 * 版本: 1.0<br>
 * 日期: 2016/9/27 19:02<br>
 **/
public class HandleFuc<T> implements Function<BaseApiResult<T>, T> {

    @Override
    public T apply(BaseApiResult<T> response) throws Exception {
        if (ApiException.isOk(response.status)) {
            return response.data;
        } else {
            throw new ApiException(response.status, response.message);
        }
    }
}
